// Password.cpp : implementation file
//

#include "stdafx.h"
#include "Tray.h"
#include "Password.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// Password dialog

Password::Password(CWnd* pParent /*=NULL*/)
	: CDialog(Password::IDD, pParent)
{
	//{{AFX_DATA_INIT(Password)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void Password::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Password)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(Password, CDialog)
	//{{AFX_MSG_MAP(Password)
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Password message handlers

void Password::OnOK() 
{
	// TODO: Add extra validation here
	GetDlgItemText(IDC_EDIT1,m_password); 

	if(m_password!="scan50")
	{
		CDialog::OnCancel();
		return;
	}
	CDialog::OnOK();
}

bool Password::EnterPWD()
{
	return (DoModal() == IDOK);
}

void Password::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}

void Password::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	tt--;

	m_time.Format("%d",tt);
	SetDlgItemText(IDC_STATIC1,m_time); 
	if(tt==0)
	{
		KillTimer(1);
		CDialog::OnCancel();
	}
	CDialog::OnTimer(nIDEvent);
}

BOOL Password::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CDialog::Create(IDD, pParentWnd);
}

BOOL Password::OnInitDialog() 
{
	CDialog::OnInitDialog();
	tt=20;
	// TODO: Add extra initialization here
	SetTimer(1,1000,NULL);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

BOOL Password::DestroyWindow() 
{
	// TODO: Add your specialized code here and/or call the base class
	KillTimer(1);
	return CDialog::DestroyWindow();
}
